package com.IR.user.action;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.IR.shop.po.Site;
import com.IR.user.service.BSiteBIZ;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

/**
 * @author 单立鑫
 * @date 2018-09-07
 * */
@Controller 
public class BSiteAction {
	
	@Resource
	private BSiteBIZ biz;
	@RequestMapping(value="showSite.do")
	public void showSite(HttpServletRequest request,HttpServletResponse response) throws IOException {
		response.setHeader("Access-Control-Allow-Origin", "*");
		response.setCharacterEncoding("utf-8");
		Long userid=new Long(request.getParameter("userid"));
		Site s=new Site();
		s=biz.showSite(userid);
		System.out.println(userid);
		PrintWriter out = response.getWriter();
		String str=JSONObject.fromObject(s).toString();
		out.println(str);
	}
	@RequestMapping(value="showUserSite.do")
	public void showUserSite(HttpServletRequest request,HttpServletResponse response) throws IOException {
		response.setHeader("Access-Control-Allow-Origin", "*");
		response.setCharacterEncoding("utf-8");
		Long userid=new Long(request.getParameter("userid"));
		List<Site> l=biz.showUserSite(userid);
		PrintWriter out = response.getWriter();
		String str=JSONArray.fromObject(l).toString();
		out.println(str);
		//测试
		/*System.out.println(l.size());
		for(Site s:l) {
			System.out.println(s.getSphone());		
		}*/
	}
	
}
